/*******************************************************************************
* * * Copyright (c) 2013 ASEG Inc.  All Rights Reserved
*  *  *
*  *  * This software is the confidential and proprietary information of
*  *  * ASEG Inc. ("Confidential Information").  You shall not
*  *  * disclose such Confidential Information and shall use it only in
*  *  * accordance with the terms of the license agreement you entered into
*  *  * with ASEG Inc.
*  *  *
*  *  * ASEG Inc. MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
*  *  * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
*  *  * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
*  *  * A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. ASEG Inc. SHALL NOT
*  *  * BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
*  *  * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*  * 
 *  *  * @version     1.0.0
*  *  * @author       Sean Kang
******************************************************************************/

package org.lionsteins.eddie.client;

import java.util.Date;

import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.datepicker.client.DateBox;
import com.google.gwt.user.datepicker.client.DateBox.Format;

/**
 * @author skang
 *
 */
public class MyDateBoxFormat implements Format {

	Format defFormat  = new DateBox.DefaultFormat();
	
	public MyDateBoxFormat (){
		super();
	}
	
	
	@Override
	public String format(DateBox dateBox, Date date) {
		if (date != null){
			@SuppressWarnings("deprecation")
			String dateString = DateTimeFormat.getMediumDateFormat().format(date);
			return dateString;
			
		} 
		
		return "";
	}

	@Override
	public Date parse(DateBox dateBox, String text, boolean reportError) {
		
		return defFormat.parse(dateBox, text, reportError);
	}

	@Override
	public void reset(DateBox dateBox, boolean abandon) {
			defFormat.reset(dateBox, abandon);
	}

}
